import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { setCollapsed } from '@/store/menu';
import { Button } from 'antd';
import axios from '@/utils/ajax';
// import axios from 'axios';

function page1() {
  const [newList, setNewList] = useState([]);
  const collapsed = useSelector((state: any) => {
    console.log(state);
    return state.menu.collapsed;
  });
  const dispatch = useDispatch();
  useEffect(() => {
    async function fetchData() {
      const res = await axios.get('juhe/toutiao/index', { params: { key: '7d4be87c31557c33cc6623f3d9bd109d', type: 'top' } });
      setNewList(res.data.result.data);
    }
    fetchData();
  }, []);
  return (
    <>
      <div>page1</div>
      <Button type="primary" onClick={() => dispatch(setCollapsed(!collapsed))}>切换</Button>
      <div>{collapsed ? '折叠' : '展开'}</div>
    </>
  );
}
export default page1;